#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/sax2/ContentHandler.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
#include <xercesc/sax2/Attributes.hpp>
#include <iostream>
#include <fstream>
#include <time.h>
#include <string>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/LocalFileInputSource.hpp>

#ifdef XERCES_CPP_NAMESPACE_USE
XERCES_CPP_NAMESPACE_USE
#endif
///ofs

std::string DataName;
class Handler : public ContentHandler
{
public:
	Handler(){}
	~Handler(){}
	void  characters (const XMLCh *const chars, const XMLSize_t length);
	
	void  endDocument (); 
 
	void  endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname);
    
	void  ignorableWhitespace (const XMLCh *const chars, const XMLSize_t length);
    
	void  processingInstruction (const XMLCh *const target, const XMLCh *const data);
 
    void  setDocumentLocator (const Locator *const locator);
  
	void  startDocument ();
 
	void  startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs);
	
	void  startPrefixMapping (const XMLCh *const prefix, const XMLCh *const uri);
 
	void  endPrefixMapping (const XMLCh *const prefix);
	
	void  skippedEntity (const XMLCh *const name);

};

void  Handler::characters (const XMLCh *const chars, const XMLSize_t length)
{
	return ;
}
	
void  Handler::endDocument ()
{
	return ;
}
 
void  Handler::endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
{
	return ;
}
    
void  Handler::ignorableWhitespace (const XMLCh *const chars, const XMLSize_t length)
{
	return ;
}
    
void  Handler::processingInstruction (const XMLCh *const target, const XMLCh *const data)
{
	return ;
}
 
void  Handler::setDocumentLocator (const Locator *const locator)
{
	return ;
}
  
void  Handler::startDocument ()
{
	return ;
}
 
void  Handler::startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
{

	char * chrTemp = XMLString::transcode(localname);
	if (  strcmp( chrTemp, DataName.c_str() ) == 0 )
	{
		const XMLCh * p = NULL;
		p = XMLString::transcode("vx");
		const XMLCh * q = new XMLCh();
		q = attrs.getValue(p);
	//	out << XMLString::transcode( q ) << std::endl;
		
		p = XMLString::transcode("vy");
		q = attrs.getValue(p);
	//	out << XMLString::transcode( q ) << std::endl;
	}
	return;
}
	
void  Handler::startPrefixMapping (const XMLCh *const prefix, const XMLCh *const uri)
{
	return ;
}
 
void  Handler::endPrefixMapping (const XMLCh *const prefix)
{
	return ;
}
	
void  Handler::skippedEntity (const XMLCh *const name)
{
	return ;
}


int main()
{
	std::ifstream in("in.txt");
	std::ofstream out("out.txt");
	std::ofstream time("time.txt");
	int n = 0;
	std::string XMLFileName;
	try
	{
		in >> n ;
	}
	catch( std::string str )
	{
		time << "error while reading input file : in.txt " << std::endl;
	}
	clock_t start,finish;

	for ( int i = 0; i < n; i++ )
	{
		in >> XMLFileName;
		in >> DataName;
		start=clock();
		Handler handler;
		XMLPlatformUtils::Initialize();
		SAX2XMLReader* pParser = XMLReaderFactory::createXMLReader();
		pParser->setContentHandler( &handler );
		pParser->parse(XMLFileName.c_str());
		finish=clock();
		time << "reading time = " << ((double)( finish - start )/(CLOCKS_PER_SEC))
			<< " secs." << std::endl;
	}


    XMLPlatformUtils::Terminate();
	return 0;
}